﻿using Microsoft.Xna.Framework;

namespace FatCatSpace.Logic.Graphics.Display.Camera
{
    public class Camera
    {
        private Vector3 _offSet;
        private Vector3 _position;

        public Camera(CameraMode cameraMode, Vector3 initialCameraPostion)
        {
            Mode = cameraMode;
            _position = initialCameraPostion;
        }

        public CameraMode Mode { get; private set; }

        public Vector3 Target { get; set; }

        public Vector3 Position
        {
            get
            {
                return _position;
            }
            private set
            {
                _position = value + OffSet;
            }
        }

        private Vector3 OffSet
        {
            get
            {
                return _offSet;
            }
            set
            {
                _offSet = value;

                _position = _position + _offSet;
            }
        }

        public Vector3 UpVector { get; set; }

        public Matrix ViewMatrix
        {
            get
            {
                return Matrix.CreateLookAt(Position, Target, UpVector);
            }
        }

        public void SetOffset(Vector3 offset)
        {
            OffSet = offset;
        }

        public void SetCameraPosition(Vector3 newPosition)
        {
            Position = newPosition;
        }
    }
}